<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>首页</title>
    <script src="javascript/jquery.min.js"></script>
    <script src="javascript/function.js"></script>
    <link rel="stylesheet" href="stylesheet/style_v1.1.css">
</head>
<body>
<div class="con">
    <!--焦点图-->
    <div id="addShow">
    </div>
    <!--功能菜单-->
<!--     <div class="col-12"> -->
<!--         <ul class="function-menu"> -->
<!--             <li> -->`
<!--                 <a href="forwardPage_activityList.action"> -->
<!--                     <img src="image/1.png" alt=""> -->
<!--                     <span>众筹</span> -->
<!--                 </a> -->
<!--             </li> -->
<!--             <li> -->
<!--                 <a href="forwardPage_tempStart.action"> -->
<!--                     <img src="image/2.png" alt=""> -->
<!--                     <span>品牌街</span> -->
<!--                 </a> -->
<!--             </li> -->
<!--             <li> -->
<!--                 <a href="forwardPage_tempStart.action"> -->
<!--                     <img src="image/3.png" alt=""> -->
<!--                     <span>时尚达人</span> -->
<!--                 </a> -->
<!--             </li> -->
<!--             <li> -->
<!--                 <a href="forwardPage_typeList.action"> -->
<!--                     <img src="image/4.png" alt=""> -->
<!--                     <span>类目</span> -->
<!--                 </a> -->
<!--             </li> -->
<!--         </ul> -->
<!--     </div> -->
    <hr>
    <!--推荐-->
    <div class="col-12 tab-btn">
        <li class="tab">
            <a href="javascript:void(0);" class="ac" id="clifford">聚福</a> | <a href="javascript:void(0);" id="activity">众筹</a>
<!--               <a href="javascript:void(0);" class="ac" id="clifford">聚福</a> | <a href="javascript:void(0);" id="recommend">推荐</a> -->
        </li>
        <!--产品-->
        <div id="cliffordlistShow" >
        </div>
          <div id="recommendlistShow" style="display:none;" >
        </div>
          <div id="activitylistShow" style="display:none;">
        </div>
    </div>
</div>
     <%@ include file="footer.jsp"%>
<script>
var cliffordpage=1;
var recommendpage=1;
var activitypage=1;
    $(function () {
    	$('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
        $('.tab').find('a').on('click', function (e) {
            e.preventDefault();
            $('.tab').find('a').removeClass('ac');
            $(this).addClass('ac');
            var id=$(this).attr("id");
            if(id=="clifford"){
//             	 $("#cliffordlistShow").css("display","");
// 				  $("#recommendlistShow").css("display","none");
// 				  $("#activitylistShow").css("display","none");
            	 queryClifford();
            }else if(id=="recommend"){
//             	 $("#cliffordlistShow").css("display","none");
// 				  $("#recommendlistShow").css("display","");
// 				  $("#activitylistShow").css("display","none");
            	queryRecommend();
            }else if(id=="activity"){
//             	 $("#cliffordlistShow").css("display","none");
// 				  $("#recommendlistShow").css("display","none");
// 				  $("#activitylistShow").css("display","");
            	queryActivity();
            }
        });
        queryAd();
        queryClifford();
        $(window).scroll(function(){
        	l_loding();
        });
    });

    function l_loding(){
        if ($(document).scrollTop() <= 0) {
            return false;
        }
        if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
        	 var selectId=$('.tab').find('.ac').attr("id");
//         	 alert(cliffordpage+":"+recommendpage+":"+activitypage);
        	if(selectId=="clifford"){
        		queryClifford();
        	}else if(selectId=="recommend"){
        		queryRecommend();
        	}else if(selectId=="activity"){
        		queryActivity();
        	}
        }
    }
    function queryAd() {
// 		var params = "parms.productTypeId=" + typeId;
		$.ajax({
					type : 'post',
					url : 'cliffordAction!queryAdList.action',
					async : false,
// 					data : params, // 传给action的参数
					success : function(data) {
						if (data.result == 1) {
							if (data.resultData.size == '0') {
								document.getElementById("addShow").innerHTML="";
// 								alert("未获取到祈福商品信息");
							} else {
								var list = data.resultData.datalist;
								var html = "";
								var count=list.length;
								if(count>3){
									count=3;
								}
								for ( var i = 0; i < count; i++) {
									if(i==0){
										html += '<div class="col-12 banner">';
									}else{
										  html += ' <div class="col-6 banner">';
									}
										
									html += ' <a href="'+list[i].adUrl+'">';
							        html += ' <img src="'+list[i].adMainImg+'" alt="">';
							        html += '</a>';
							        html += ' </div>';
								}
								document.getElementById("addShow").innerHTML = html;
							}
						} else {
							document.getElementById("addShow").innerHTML="";
// 							alert(data.msg);
						}
					}
				});
	} 
    function queryClifford() {
		var params = "parms.cliffordpage=" + cliffordpage;
		$.ajax({
					type : 'post',
					url : 'cliffordAction!queryCliffordList.action',
					async : false,
					data : params, // 传给action的参数
					success : function(data) {
						 $("#cliffordlistShow").css("display","");
						  $("#recommendlistShow").css("display","none");
						  $("#activitylistShow").css("display","none");
						  
						if (data.result == 1) {
							if (data.resultData.size == '0') {
// 								document.getElementById("cliffordlistShow").innerHTML="";
								alert("未获取到祈福商品信息");
							} else {
								cliffordpage=cliffordpage+1;
								var list = data.resultData.datalist;
// 								 $('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								 $('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
								var html =document.getElementById("cliffordlistShow").innerHTML;
								for ( var i = 0; i < list.length; i++) {
									html += '<div class="work-info" >';
									html += ' <div class="work-img">';
									html += '<img src="'+list[i].zjfGood.goodsMainPhoto+'" alt="">';
									html += ' </div>';
									html += ' <div class="work-text">';
									html += '<p class="work-name">'+list[i].zjfGood.goodsName+'</p>';
									html += '<p class="work-money">￥<span>'+list[i].zjfGood.goodsName+'</span></p>';
									html += ' <a class="work-btn" href="forwardPageParam_cliffordDetail.action?parms.goodsId='+list[i].zjfGood.goodsId+'">去聚福</a>';
// 									html += ' <a class="work-btn" href="javascript:void(0);" onclick="startClifford(\''+list[0].zjfGood.goodsId+'\');">去聚福</a>';
									html += '</div>';
									html += ' </div>';
								}
								document.getElementById("cliffordlistShow").innerHTML = html;
// 								 $('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								 $('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
							}
						} else {
// 							document.getElementById("cliffordlistShow").innerHTML="";
							alert(data.msg);
						}
					}
				});
	} 
    function queryRecommend() {
		var params = "parms.recommendpage=" + recommendpage;
		$.ajax({
					type : 'post',
					url : 'cliffordAction!queryRecommendList.action',
					async : false,
					data : params, // 传给action的参数
					success : function(data) {
						 $("#cliffordlistShow").css("display","none");
						  $("#recommendlistShow").css("display","");
						  $("#activitylistShow").css("display","none");
						if (data.result == 1) {
							if (data.resultData.size == '0') {
								document.getElementById("recommendlistShow").innerHTML="";
								alert("未获取到推荐商品信息");
							} else {
								recommendpage=recommendpage+1;
// 								$('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								$('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
								var list = data.resultData.datalist;
								var html = document.getElementById("recommendlistShow").innerHTML;
								for ( var i = 0; i < list.length; i++) {
									html += '<div class="work-info" >';
									html += ' <div class="work-img">';
									html += '<img src="'+list[i].zjfGood.goodsMainPhoto+'" alt="">';
									html += ' </div>';
									html += ' <div class="work-text">';
									html += '<p class="work-name">'+list[i].zjfGood.goodsName+'</p>';
									html += '<p class="work-money">￥<span>'+list[i].zjfGood.goodsName+'</span></p>';
									html += ' <a class="work-btn" href="forwardPageParam_cliffordDetail.action?parms.goodsId='+list[i].zjfGood.goodsId+'">去聚福</a>';
// 									html += ' <a class="work-btn" href="forwardPage_cliffordDetail.action" onclick="startClifford(\''+list[0].zjfGood.goodsId+'\');">去聚福</a>';
									html += '</div>';
									html += ' </div>';
								}
								document.getElementById("recommendlistShow").innerHTML = html;
// 								$('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								$('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
							}
						} else {
							document.getElementById("recommendlistShow").innerHTML="";
							alert(data.msg);
						}
					}
				});
	}
    function queryActivity() {
		var params = "parms.activitypage=" + activitypage;
		$.ajax({
					type : 'post',
					url : 'cliffordAction!queryActivityList.action',
					async : false,
					data : params, // 传给action的参数
					success : function(data) {
						 $("#cliffordlistShow").css("display","none");
						  $("#recommendlistShow").css("display","none");
						  $("#activitylistShow").css("display","");
						if (data.result == 1) {
							if (data.resultData.size == '0') {
// 								document.getElementById("activitylistShow").innerHTML="";
								alert("未获取到众筹活动信息");
							} else {
								activitypage=activitypage+1;
// 								$('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								$('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
								var list = data.resultData.datalist;
								var html =document.getElementById("activitylistShow").innerHTML ;
								for ( var i = 0; i < list.length; i++) {
									html += '<div class="work-info" >';
									html += ' <div class="work-img">';
									html += '<img src="'+list[i].zjfGoodsActivity.activityImg+'" alt="">';
									html += ' </div>';
									html += ' <div class="work-text">';
									html += '<p class="work-name">'+list[i].zjfGoodsActivity.activityName+'</p>';
									html += '<p class="work-money">筹集金额￥<span>'+list[i].zjfGoodsActivityRecord.total+'</span></p>';
									html += ' <a class="work-btn" href="forwardPageParam_activityDetail.action?parms.activityId='+list[i].zjfGoodsActivity.activityId+'">查看详情</a>';
									html += '</div>';
									html += ' </div>';
								}
								document.getElementById("activitylistShow").innerHTML = html;
// 								$('.work-text').css({"width": $('.work-info').width() - 158 + "px"});
								$('.work-text').css({"width": $(window).innerWidth()-40-160+ "px"});
							}
						} else {
// 							document.getElementById("activitylistShow").innerHTML="";
							alert(data.msg);
						}
					}
				});
	}
</script>
</body>
</html>